<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Expires" content="-1" />
<link rel="stylesheet" href="lib/jquery_mobile_lastest/jquery_mobile_lastest.css" />
<script type="text/javascript" src="lib/jquery_lastest.js"></script>
<script src="lib/jquery_mobile_lastest/jquery_mobile_lastest.js"></script>
<!-- <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&language=zh-CN"></script> -->
<script type="text/javascript">
	function detectBrowser() {
		var useragent = navigator.userAgent;
		var mapdiv = document.getElementById("res");
			
		if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 ) {
			mapdiv.style.width = '100%';
			mapdiv.style.height = '100%';
		} else {
			//mapdiv.style.width = '480px';
			//mapdiv.style.height = '800px';
		}
	}
	function distance1(lat1,lon1,lat2,lon2) {
	var R = 6371; // km (change this constant to get miles)
	var dLat = (lat2-lat1) * Math.PI / 180;
	var dLon = (lon2-lon1) * Math.PI / 180; 
	var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
		Math.cos(lat1 * Math.PI / 180 ) * Math.cos(lat2 * Math.PI / 180 ) * 
		Math.sin(dLon/2) * Math.sin(dLon/2); 
	var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
	var d = R * c;
	if (d>1) return Math.round(d)+"km";
	else if (d<=1) return Math.round(d*1000)+"m";
	return d;
}
	function distance(sX,sY,eX,eY){  
		var lat = [sX, eX]  
		var lng = [sY, eY] //var R = 6371; // km (change this constant to get miles)  
		var R = 6378137; // In meters  
		var dLat = (lat[1] - lat[0]) * Math.PI / 180;  
		var dLng = (lng[1] - lng[0]) * Math.PI / 180;  
		var dLat1 = lat[0] * Math.PI / 180;  
		var dLat2 = lat[1] * Math.PI / 180;  
		var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(dLat1) * Math.cos(dLat1) * Math.sin(dLng / 2) * Math.sin(dLng / 2);  
		var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));  
		var d = R * c;  
		if (d>1000) return (Math.round(d)/1000).toFixed(3)+"公里";
		else if (d<=1000) return Math.round(d)+"米";
		//return Math.round(d); 
		return d;
	}
	$(function() {
		detectBrowser();
		//var w=document.body.clientWidth;
		//var h=document.body.clientHeight;
		var w=document.body.clientWidth;
		var h=window.screen.height;
		//alert(h);
		if(h>640){h=400;}else{h=300;}
		var customer_address_lat=$("#customer_address_lat").html();
		var customer_address_lng=$("#customer_address_lng").html();
		var cl_lat=$("#cl_lat").html();
		var cl_lng=$("#cl_lng").html();
		$("#distance").html("目前距离目的地直线："+distance(customer_address_lat,customer_address_lng,cl_lat,cl_lng));
		$("#map").html("<img src='http://maps.google.com/maps/api/staticmap?size="+w+"x"+h+"&markers=color:red|label:C|"+customer_address_lat+","+customer_address_lng+"&markers=color:green|label:I|"+cl_lat+","+cl_lng+"&path=color:0x0000ff88|weight:5|"+customer_address_lat+","+customer_address_lng+"|"+cl_lat+","+cl_lng+"&mobile=true&sensor=true' />");
	});
	
</script>

</head>
<%
	ybid=saferequest("ybid",1)
	o=saferequest("o",0)
	if o="accept" then sql="update progress set progress_accept=now() where progress_yb="&ybid
	if o="tx" then sql="update progress set progress_tx=now() where progress_yb="&ybid
	if o="reach" then sql="update progress set progress_reach=now() where progress_yb="&ybid
	if o="left" then sql="update progress set progress_left=now() where progress_yb="&ybid
	if o="arrival" then sql="update progress set progress_arrival=now() where progress_yb="&ybid
	if o="end" then sql="update progress set progress_end=now(), progress_done=true where progress_yb="&ybid
	if o<>"" then
		set cmd=server.CreateObject ("adodb.command")
		set cmd.ActiveConnection =conn
		cmd.CommandText =sql
		cmd.Execute
		
	end if
	Set rs = Server.CreateObject("ADODB.Recordset")
	sql="select * from (((select id,rq,sj,yb_customer,cyr,dd,xx,attentions,tx,hx from yb where id="&ybid&") as y left join customer on y.yb_customer=customer.customer_id) left join progress on y.id=progress.progress_yb) left join cl on cl.clid=progress.progress_cl"
	rs.open sql,conn,1,1
	if not rs.eof then
%>
<body>
<div id="res" data-role="page" >

	<div data-role="header">
		<a href="deal.asp?clid=<%=rs("cyr")%>" data-role="button" data-icon="arrow-l" class="ui-btn-left"  rel="external">返回</a>
		<h1><%if rs("customer_name")="" or isnull(rs("customer_name")) then response.write("&nbsp;") else response.write(rs("customer_name"))%></h1>
		<% if rs("progress_accept")="" or isnull(rs("progress_accept")) then	%>
		<a href="deal_info.asp?ybid=<%=ybid%>&o=accept" data-role="button" data-icon="check" class="ui-btn-right" rel="external">接单</a>
		<% elseif rs("progress_tx")="" or isnull(rs("progress_tx")) then %>
		<a href="deal_info.asp?ybid=<%=ybid%>&o=tx" data-role="button" data-icon="check" class="ui-btn-right" rel="external">提箱</a>
		<% elseif rs("progress_reach")="" or isnull(rs("progress_reach")) then %>
		<a href="deal_info.asp?ybid=<%=ybid%>&o=reach" data-role="button" data-icon="check" class="ui-btn-right" rel="external">到厂</a>
		<% elseif rs("progress_left")="" or isnull(rs("progress_left")) then %>
		<a href="deal_info.asp?ybid=<%=ybid%>&o=left" data-role="button" data-icon="check" class="ui-btn-right" rel="external">离厂</a>
		<% elseif rs("progress_arrival")="" or isnull(rs("progress_arrival")) then %>
		<a href="deal_info.asp?ybid=<%=ybid%>&o=arrival" data-role="button" data-icon="check" class="ui-btn-right" rel="external">进港</a>
		<% elseif rs("progress_end")="" or isnull(rs("progress_end")) then %>
		<a href="deal_info.asp?ybid=<%=ybid%>&o=end" data-role="button" data-icon="check" class="ui-btn-right" rel="external">完成</a>
		<% end if%>
	</div>

	<div data-role="content" style="padding: 0;">
		<input id="ybid" type="hidden" value="<%=ybid%>" />
		<table width="100%">
			<tr>
				<td colspan="4" style="font-weight:bold;"><%=rs("customer_address")%></td>
			</tr>
			<tr>
				<td colspan="2"><%=rs("customer_owner")%></td>
				<td colspan="2"><%=rs("customer_phone")%></td>
			</tr>
			<tr>
				<td><%=rs("dd")%></td>
				<td><%=rs("xx")%>货柜</td>
				<td colspan="2"><%=shortdate(rs("rq"))%>&nbsp;<%=ShortTime(rs("sj"))%></td>
			</tr>
			<tr>
				<td>提箱：</td>
				<td><%=rs("tx")%></td>
				<td>还箱：</td>
				<td><%=rs("hx")%></td>
			</tr>
			<tr>
				<td colspan="4" style="color:red;font-weight:bold;"><%=rs("attentions")%></td>
			</tr>
		</table>
		<table width="100%">
			<tr>
				<td width="20%">下单：</td>
				<td width="30%"><%=shortdate(rs("progress_start"))&"&nbsp;"&ShortTime(rs("progress_start"))%></td>
				<td width="20%">接单：</td>
				<td width="30%"><%=shortdate(rs("progress_accept"))&"&nbsp;"&ShortTime(rs("progress_accept"))%></td>
			</tr>
			<tr>
				<td width="20%">提箱：</td>
				<td width="30%"><%=shortdate(rs("progress_tx"))&"&nbsp;"&ShortTime(rs("progress_tx"))%></td>
				<td width="20%">到厂：</td>
				<td width="30%"><%=shortdate(rs("progress_reach"))&"&nbsp;"&ShortTime(rs("progress_reach"))%></td>
			</tr>
			<tr>
				<td width="20%">离厂：</td>
				<td width="30%"><%=shortdate(rs("progress_left"))&"&nbsp;"&ShortTime(rs("progress_left"))%></td>
				<td width="20%">进港：</td>
				<td width="30%"><%=shortdate(rs("progress_arrival"))&"&nbsp;"&ShortTime(rs("progress_arrival"))%></td>
			</tr>
			<tr>
				<td id="distance" colspan="4" style="color:blue;font-weight:bold;	filter:alpha(opacity=80);	-moz-opacity:0.8;	-khtml-opacity: 0.8;	opacity: 0.8;"></td>
			</tr>
		</table>
		<div id="result"></div>
	</div><!-- /content -->
	<div style="display:none">
		<div id="customer_address_lat"><%=rs("customer_address_lat")%></div>
		<div id="customer_address_lng"><%=rs("customer_address_lng")%></div>
		<div id="cl_lat"><%=rs("cl_lat")%></div>
		<div id="cl_lng"><%=rs("cl_lng")%></div>
	</div><!-- 两点的经纬度 -->
	<div id="map"></div>
	<!-- 原始静态api
	<img src="http://maps.google.com/maps/api/staticmap?size=480x400&markers=color:red|label:C|<%=rs("customer_address_lat")%>,<%=rs("customer_address_lng")%>&markers=color:green|label:I|<%=rs("cl_lat")%>,<%=rs("cl_lng")%>&mobile=true&sensor=true" />
	-->

</div>
</body>
<%
	end if
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>
</html>
